<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="上传代码" prop="uploadCode">
        <el-input
          v-model="queryParams.uploadCode"
          placeholder="请输入上传代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批次代码" prop="uploadCodeBatch">
        <el-input
          v-model="queryParams.uploadCodeBatch"
          placeholder="请输入批次代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="店铺代码" prop="shopCode">
        <el-input
          v-model="queryParams.shopCode"
          placeholder="请输入店铺代码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="站点" prop="countryCode">
        <el-select v-model="queryParams.countryCode" placeholder="请选择站点" clearable size="small">
          <el-option
            v-for="dict in countryCodeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="产品状态" prop="productFeedStatus">
        <el-select v-model="queryParams.productFeedStatus" placeholder="请选择产品状态" clearable size="small">
          <el-option
            v-for="dict in productFeedStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="库存状态" prop="inventoryFeedStatus">
        <el-select v-model="queryParams.inventoryFeedStatus" placeholder="请选择库存状态" clearable size="small">
          <el-option
            v-for="dict in inventoryFeedStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="价格状态" prop="pricingFeedStatus">
        <el-select v-model="queryParams.pricingFeedStatus" placeholder="请选择价格状态" clearable size="small">
          <el-option
            v-for="dict in pricingFeedStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="图片状态" prop="productimageFeedStatus">
        <el-select v-model="queryParams.productimageFeedStatus" placeholder="请选择图片状态" clearable size="small">
          <el-option
            v-for="dict in productimageFeedStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="关系状态" prop="relationshipFeedStatus">
        <el-select v-model="queryParams.relationshipFeedStatus" placeholder="请选择关系状态" clearable size="small">
          <el-option
            v-for="dict in relationshipFeedStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="任务状态" prop="taskStatus">
        <el-select v-model="queryParams.taskStatus" placeholder="请选择关系状态" clearable size="small">
          <el-option
            v-for="dict in taskStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="开始时间" prop="beginUpdateTime">
        <el-date-picker clearable size="small" :style="{width: '92%'}"
          v-model="queryParams.beginUpdateTime"
          type="date"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="截止时间" prop="endUpdateTime">
        <el-date-picker clearable size="small" :style="{width: '92%'}"
          v-model="queryParams.endUpdateTime"
          type="date"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="选择截止时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['amz:productAmzUploadTask:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['amz:productAmzUploadTask:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['amz:productAmzUploadTask:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-upload2"
          size="mini"
          @click="handleExport"
          v-hasPermi="['amz:productAmzUploadTask:export']"
        >导出</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-upload"
          size="mini"
          :disabled="multiple"
          @click="handleUploadTask"
          v-hasPermi="['amz:productAmzUploadTask:uploadTask']"
          title="若未上传成功，可通过编辑状态值后进行重新上传（重新加入上传队列 / 置顶）"
        >重新上传</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-upload"
          size="mini"
          :disabled="multiple"
          @click="handleGetUploadFeedsReport"
          v-hasPermi="['amz:productAmzUploadTask:getUploadFeedsReport']"
        >获取报告</el-button>
      </el-col>

	    <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="productAmzUploadTaskList" @selection-change="handleSelectionChange">

      <el-table-column type="expand">
        <template slot-scope="props">
          <el-form label-position="left" inline class="demo-table-expand">
            <el-form-item label="产品代码">
              <span>{{ props.row.productCodes }}</span>
            </el-form-item>

            <el-form-item label="产品FeedId">
              <span>{{ props.row.productFeedId }}</span>
            </el-form-item>
            <el-form-item label="库存FeedId">
              <span>{{ props.row.inventoryFeedId }}</span>
            </el-form-item>
            <el-form-item label="价格FeedId">
              <span>{{ props.row.pricingFeedId }}</span>
            </el-form-item>
            <el-form-item label="图片FeedId">
              <span>{{ props.row.productimageFeedId }}</span>
            </el-form-item>
            <el-form-item label="关系FeedId">
              <span>{{ props.row.relationshipFeedId }}</span>
            </el-form-item>

            <el-form-item label="产品响应">
              <span v-if="props.row.productFeedResponse!=null && props.row.productFeedResponse.startsWith('http')" >具体上传结果，请点击查看<a :href=props.row.productFeedResponse target="_blank" style="color: blue;">上传报告详情</a></span>
              <span v-else>{{props.row.productFeedResponse}}</span>
            </el-form-item>
            <el-form-item label="库存响应">
              <span v-if="props.row.inventoryFeedResponse!=null && props.row.inventoryFeedResponse.startsWith('http')" >具体上传结果，请点击查看<a :href=props.row.inventoryFeedResponse target="_blank" style="color: blue;">上传报告详情</a></span>
              <span v-else>{{ props.row.inventoryFeedResponse }}</span>
            </el-form-item>
            <el-form-item label="价格响应">
              <span v-if="props.row.pricingFeedResponse!=null && props.row.pricingFeedResponse.startsWith('http')" >具体上传结果，请点击查看<a :href=props.row.pricingFeedResponse target="_blank" style="color: blue;">上传报告详情</a></span>
              <span v-else>{{ props.row.pricingFeedResponse }}</span>
            </el-form-item>
            <el-form-item label="图片响应">
              <span v-if="props.row.productimageFeedResponse!=null && props.row.productimageFeedResponse.startsWith('http')" >具体上传结果，请点击查看<a :href=props.row.productimageFeedResponse target="_blank" style="color: blue;">上传报告详情</a></span>
              <span v-else>{{ props.row.productimageFeedResponse }}</span>
            </el-form-item>
            <el-form-item label="变体响应">
              <span v-if="props.row.relationshipFeedResponse!=null && props.row.relationshipFeedResponse.startsWith('http')" >具体上传结果，请点击查看<a :href=props.row.relationshipFeedResponse target="_blank" style="color: blue;">上传报告详情</a></span>
              <span v-else>{{ props.row.relationshipFeedResponse }}</span>
            </el-form-item>
            <el-form-item label="备注">
              <span>{{ props.row.remark }}</span>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column>
      <el-table-column type="selection" width="45" align="center" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['amz:productAmzUploadTask:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['amz:productAmzUploadTask:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
      <el-table-column label="上传代码" align="center" prop="uploadCode" width="155"/>
      <el-table-column label="批次代码" align="center" prop="uploadCodeBatch" width="160" show-overflow-tooltip/>
      <el-table-column label="站点" align="center" prop="countryCode" :formatter="countryCodeFormat" width="80"/>
      <el-table-column label="店铺代码" align="center" prop="shopCode" width="120" show-overflow-tooltip/>
      <el-table-column label="产品状态" align="center" prop="productFeedStatus" :formatter="productFeedStatusFormat" width="80"/>
      <el-table-column label="库存状态" align="center" prop="inventoryFeedStatus" :formatter="inventoryFeedStatusFormat" width="80"/>
      <el-table-column label="价格状态" align="center" prop="pricingFeedStatus" :formatter="pricingFeedStatusFormat" width="80"/>
      <el-table-column label="图片状态" align="center" prop="productimageFeedStatus" :formatter="productimageFeedStatusFormat" width="80"/>
      <el-table-column label="关系状态" align="center" prop="relationshipFeedStatus" :formatter="relationshipFeedStatusFormat" width="80"/>
      <el-table-column label="任务状态" align="center" prop="taskStatus" :formatter="taskStatusFormat" width="80"/>
      <el-table-column label="上传时间" align="center" prop="uploadTime" width="160" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.uploadTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新人" align="center" prop="updateBy" width="80" show-overflow-tooltip/>
      <el-table-column label="更新时间" align="center" prop="updateTime" width="100" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改上传任务对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" :close-on-click-modal="false" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="上传代码" prop="uploadCode" >
              <el-input v-model="form.uploadCode" placeholder="请输入上传代码" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="批次代码" prop="uploadCodeBatch">
              <el-input v-model="form.uploadCodeBatch" placeholder="请输入批次代码" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="站点" prop="countryCode">
              <el-select v-model="form.countryCode" placeholder="请选择站点" :style="{width: '100%'}" :disabled="true" >
                <el-option
                  v-for="dict in countryCodeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="产品代码" prop="productCodes">
              <el-input v-model="form.productCodes" placeholder="请输入内容" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="店铺代码" prop="shopCode">
              <el-input v-model="form.shopCode" placeholder="请输入店铺代码" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="产品状态" prop="productFeedStatus">
              <el-select v-model="form.productFeedStatus" placeholder="请选择产品状态" :style="{width: '100%'}" >
                <el-option
                  v-for="dict in productFeedStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="库存状态" prop="inventoryFeedStatus">
              <el-select v-model="form.inventoryFeedStatus" placeholder="请选择库存状态" :style="{width: '100%'}" >
                <el-option
                  v-for="dict in inventoryFeedStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="价格状态" prop="pricingFeedStatus">
              <el-select v-model="form.pricingFeedStatus" placeholder="请选择价格状态" :style="{width: '100%'}" >
                <el-option
                  v-for="dict in pricingFeedStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="图片状态" prop="productimageFeedStatus">
              <el-select v-model="form.productimageFeedStatus" placeholder="请选择图片状态" :style="{width: '100%'}" >
                <el-option
                  v-for="dict in productimageFeedStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="关系状态" prop="relationshipFeedStatus">
              <el-select v-model="form.relationshipFeedStatus" placeholder="请选择关系状态" :style="{width: '100%'}" >
                <el-option
                  v-for="dict in relationshipFeedStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="任务状态" prop="taskStatus">
              <el-select v-model="form.taskStatus" placeholder="请选择关系状态" :style="{width: '100%'}" >
                <el-option
                  v-for="dict in taskStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="产品XML" prop="productFeedXml">
              <el-input v-model="form.productFeedXml" placeholder="请输入产品XML" :readonly="true" />
            </el-form-item>
            <el-form-item label="库存XML" prop="inventoryFeedXml">
              <el-input v-model="form.inventoryFeedXml" placeholder="请输入库存XML" :readonly="true" />
            </el-form-item>
            <el-form-item label="价格XML" prop="pricingFeedXml">
              <el-input v-model="form.pricingFeedXml" placeholder="请输入价格XML" :readonly="true" />
            </el-form-item>
            <el-form-item label="图片XML" prop="productimageFeedXml">
              <el-input v-model="form.productimageFeedXml" placeholder="请输入图片XML" :readonly="true" />
            </el-form-item>
            <el-form-item label="关系XML" prop="relationshipFeedXml">
              <el-input v-model="form.relationshipFeedXml" placeholder="请输入关系XML" :readonly="true" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="产品FeedId" prop="productFeedId">
              <el-input v-model="form.productFeedId" placeholder="请输入产品FeedId" :readonly="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="库存FeedId" prop="inventoryFeedId">
              <el-input v-model="form.inventoryFeedId" placeholder="请输入库存FeedId" :readonly="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="价格FeedId" prop="pricingFeedId">
              <el-input v-model="form.pricingFeedId" placeholder="请输入价格FeedId" :readonly="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="图片FeedId" prop="productimageFeedId">
              <el-input v-model="form.productimageFeedId" placeholder="请输入图片FeedId" :readonly="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="关系FeedId" prop="relationshipFeedId">
              <el-input v-model="form.relationshipFeedId" placeholder="请输入关系FeedId" :readonly="true"/>
            </el-form-item>
          </el-col>

          <el-col>
            <el-form-item label="产品响应" prop="productFeedResponse">
              <el-input v-model="form.productFeedResponse" placeholder="请输入产品响应"/>
            </el-form-item>
            <el-form-item label="库存响应" prop="inventoryFeedResponse">
              <el-input v-model="form.inventoryFeedResponse" placeholder="请输入库存响应"/>
            </el-form-item>
            <el-form-item label="价格响应" prop="pricingFeedResponse">
              <el-input v-model="form.pricingFeedResponse" placeholder="请输入价格响应"/>
            </el-form-item>
            <el-form-item label="图片响应" prop="productimageFeedResponse">
              <el-input v-model="form.productimageFeedResponse" placeholder="请输入图片响应"/>
            </el-form-item>
            <el-form-item label="关系响应" prop="relationshipFeedResponse">
              <el-input v-model="form.relationshipFeedResponse" placeholder="请输入关系响应"/>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listProductAmzUploadTask, getProductAmzUploadTask, delProductAmzUploadTask, addProductAmzUploadTask, updateProductAmzUploadTask
  , exportProductAmzUploadTask
  , uploadTask
  , getUploadFeedsReport

} from "@/api/amz/productAmzUploadTask";
import { getConfigCategoryByDept } from "@/api/amz/configCategory";

export default {
  name: "ProductAmzUploadTask",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 上传任务表格数据
      productAmzUploadTaskList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 主键自增字典
      idOptions: [],
      // 产品类别列表-部门
      configCategoryOptions: [],
      // 站点字典
      countryCodeOptions: [],
      // 市场编号字典
      marketplaceIdOptions: [],
      // 产品状态字典
      productFeedStatusOptions: [],
      // 库存状态字典
      inventoryFeedStatusOptions: [],
      // 价格状态字典
      pricingFeedStatusOptions: [],
      // 图片状态字典
      productimageFeedStatusOptions: [],
      // 关系状态字典
      relationshipFeedStatusOptions: [],
      // 任务状态字典
      taskStatusOptions: [],

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        uploadCode: null,
        uploadCodeBatch: null,
        countryCode: null,
        productCodes: null,
        shopCode: null,
        productFeedStatus: null,
        inventoryFeedStatus: null,
        pricingFeedStatus: null,
        productimageFeedStatus: null,
        relationshipFeedStatus: null,
        taskStatus: null,
        beginUpdateTime: null,//更新日期开始
        endUpdateTime: null,//更新日期截止
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        uploadCode: [
          { required: true, message: "上传代码不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    /* 获取类目配置-部门*/
    this.getConfigCategoryByDept();

    this.getDicts("qc_country_code").then(response => {
      this.countryCodeOptions = response.data;
    });
    this.getDicts("amz_marketplace_id").then(response => {
      this.marketplaceIdOptions = response.data;
    });

    this.getDicts("qc_feed_status").then(response => {
      this.productFeedStatusOptions = response.data;
      this.inventoryFeedStatusOptions = response.data;
      this.pricingFeedStatusOptions = response.data;
      this.productimageFeedStatusOptions = response.data;
      this.relationshipFeedStatusOptions = response.data;
    });
    this.getDicts("qc_task_status").then(response => {
      this.taskStatusOptions = response.data;
    });

  },
  methods: {
    /** 查询上传任务列表 */
    getList() {
      this.loading = true;
      listProductAmzUploadTask(this.queryParams).then(response => {
        this.productAmzUploadTaskList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /* 获取类目配置-部门*/
    getConfigCategoryByDept(){
      getConfigCategoryByDept().then(response => {
        this.configCategoryOptions = response.data;
      });
    },
    // 站点字典翻译
    countryCodeFormat(row, column) {
      return this.selectDictLabel(this.countryCodeOptions, row.countryCode);
    },
    // 市场编号字典翻译
    marketplaceIdFormat(row, column) {
      return this.selectDictLabel(this.marketplaceIdOptions, row.marketplaceId);
    },
    // 产品状态字典翻译
    productFeedStatusFormat(row, column) {
      return this.selectDictLabel(this.productFeedStatusOptions, row.productFeedStatus);
    },
    // 库存状态字典翻译
    inventoryFeedStatusFormat(row, column) {
      return this.selectDictLabel(this.inventoryFeedStatusOptions, row.inventoryFeedStatus);
    },
    // 价格状态字典翻译
    pricingFeedStatusFormat(row, column) {
      return this.selectDictLabel(this.pricingFeedStatusOptions, row.pricingFeedStatus);
    },
    // 图片状态字典翻译
    productimageFeedStatusFormat(row, column) {
      return this.selectDictLabel(this.productimageFeedStatusOptions, row.productimageFeedStatus);
    },
    // 关系状态字典翻译
    relationshipFeedStatusFormat(row, column) {
      return this.selectDictLabel(this.relationshipFeedStatusOptions, row.relationshipFeedStatus);
    },
    // 任务状态字典翻译
    taskStatusFormat(row, column) {
      return this.selectDictLabel(this.taskStatusOptions, row.taskStatus);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        uploadCode: null,
        uploadCodeBatch: null,
        countryCode: null,
        marketplaceId: null,
        productCodes: null,
        shopCode: null,
        productFeedStatus: null,
        inventoryFeedStatus: null,
        pricingFeedStatus: null,
        productimageFeedStatus: null,
        relationshipFeedStatus: null,
        productFeedXml: null,
        inventoryFeedXml: null,
        pricingFeedXml: null,
        productimageFeedXml: null,
        relationshipFeedXml: null,

        productFeedId: null,
        inventoryFeedId: null,
        pricingFeedId: null,
        productimageFeedId: null,
        relationshipFeedId: null,

        productFeedResponse: null,
        inventoryFeedResponse: null,
        pricingFeedResponse: null,
        productimageFeedResponse: null,
        relationshipFeedResponse: null,
        taskStatus: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加上传任务";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getProductAmzUploadTask(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改上传任务";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateProductAmzUploadTask(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addProductAmzUploadTask(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除上传任务编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delProductAmzUploadTask(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有上传任务数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportProductAmzUploadTask(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    },
    /**
     * 重新上传
     */
    handleUploadTask(row){
      const ids = row.id || this.ids;

      const reqParam = new FormData();
      reqParam.append("ids", ids);

      uploadTask(reqParam).then(response => {
        this.getList();
        this.msgSuccess(response.msg);
      });

    },
    /**
     * 获取报告
     * @param row
     */
    handleGetUploadFeedsReport(row){
      const ids = row.id || this.ids;

      const reqParam = new FormData();
      reqParam.append("ids", ids);
      this.loading = true;
      getUploadFeedsReport(reqParam).then(response => {
        this.getList();
        this.msgSuccess(response.msg);
        this.loading = false;
      }).catch((response) => {
        this.loading = false;
      });;

    }

  }
};
</script>
<style>
  /*展开行样式*/
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 100%;
  }
</style>
